package com.wzx.user.controller;

import com.wzx.common.core.controller.AbstractCoreController;
import com.wzx.common.exception.LeadNewsException;
import com.wzx.common.pojo.resp.Result;
import com.wzx.user.pojo.Notes;
import com.wzx.user.service.NotesService;
import com.wzx.user.vo.NotesVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author wzx
 * @version 1.0
 * @date 2023/3/1 - 22:51
 * @description 标题
 */
@Slf4j
@RestController
@RequestMapping("/notes")
@Api(tags = "充值记录")
public class NotesController extends AbstractCoreController<Notes> {

    @Autowired
    private NotesService notesService;

    @Autowired
    protected NotesController(NotesService notesService) {
        super(notesService);
        this.notesService = notesService;
    }

    @GetMapping("/queryNotesList")
    public Result queryNotesList(Integer userId,String method) throws LeadNewsException {
        List<Notes> list = notesService.queryNotesList(method,userId);
        return Result.ok(list);
    }

    @PostMapping("/queryPayAndIncome")
    @ApiOperation(value = "查询收入和支出")
    public Result queryPayAndIncome(@RequestBody NotesVo notesVo) throws LeadNewsException {
        Map<String,Object> map = notesService.queryPayAndIncome(notesVo);
        return Result.ok(map);
    }


    @PostMapping("/queryPayAndIncomeByPage")
    @ApiOperation(value = "根据，页数查询收入，支出")
    public Result queryPayAndIncomeByPage(@RequestBody NotesVo notesVo) throws LeadNewsException {
        return notesService.queryPayAndIncomeByPage(notesVo);
    }


}
